package com.administrator.cloudapplication.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;

/**
 * package: com.ftgj.luoyangculture.widgets.NoScrollGridView
 * author: gyc
 * description:使用向右位移，指定GridView的显示模式为AT_MOST，使得能显示所有的GridView的内容项
 * time: create at 2017/4/18 14:11
 */

public class NoScrollGridView extends GridView {

    public NoScrollGridView(Context context) {
        super(context);
    }


    public NoScrollGridView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }


    public NoScrollGridView(Context context, AttributeSet attrs,
                            int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        //创建一个整形值，其高两位代表mode类型，其余30位代表长或宽的实际值。
        // 可以是WRAP_CONTENT、MATCH_PARENT或具体大小exactly size
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
                MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
}
